from django.db import models

# Create your models here.
class Course(models.Model):
	Subject_ID = models.CharField(max_length=10)
	Subject_Name = models.CharField(max_length=30,blank=True)
	Section_ID = models.IntegerField(blank=False, null=False ,unique=True)

	def __unicode__(self):
		return "%d"%(self.Section_ID)

class Section(models.Model):
	Section_ID = models.ForeignKey(Course,blank=False, null=True ,unique=True)
	List_TA = models.CharField(max_length=100,blank=True)
	List_Teacher = models.CharField(max_length=100,blank=True)
	Amount_Student = models.IntegerField(blank=True)

	def __unicode__(self):
		return str(self.Section_ID)

class Student(models.Model):
	Student_ID = models.CharField(max_length=10)
	Student_Name = models.CharField(max_length=30)
	Student_Lastname = models.CharField(max_length=30)
	Section_ID = models.ForeignKey(Section,blank=False, null=True)
	Lab_ID = models.IntegerField(max_length=10,unique=True)
	Midterm_ID = models.IntegerField(max_length=10,unique=True)
	Final_ID = models.IntegerField(max_length=10,unique=True)
	Total_Score = models.IntegerField(blank=True)
	grade = models.CharField(max_length=2,blank=True)

	def __unicode__(self):
		return "%s (%s)"%(self.Lab_ID,self.Student_ID)

class Lab(models.Model):
	Lab_ID = models.ForeignKey(Student,to_field='Lab_ID',blank=False, null=True)
	Score_Lab1 = models.IntegerField(blank=True, null=False)
	Score_Lab2 = models.IntegerField(blank=True, null=False)
	Score_Lab3 = models.IntegerField(blank=True, null=False)
	Score_Lab4 = models.IntegerField(blank=True, null=False)
	
	def __unicode__(self):
		return "%s"%(self.Score_Lab1+self.Score_Lab2+self.Score_Lab3+self.Score_Lab4)

class Midterm(models.Model):
	Midterm_ID = models.ForeignKey(Student,to_field='Midterm_ID',blank=False, null=True)
	Score_Midterm1 = models.IntegerField(blank=True, null=False)
	Score_Midterm2 = models.IntegerField(blank=True, null=False)
	Score_Midterm3 = models.IntegerField(blank=True, null=False)
	Score_Midterm4 = models.IntegerField(blank=True, null=False)

	def __unicode__(self):
		return "%s"%(self.Score_Midterm1+self.Score_Midterm2+self.Score_Midterm3+self.Score_Midterm4)

class Final(models.Model):
	Final_ID = models.ForeignKey(Student,to_field='Final_ID',blank=False, null=True)
	Score_Final1 = models.IntegerField(blank=True, null=False)
	Score_Final2 = models.IntegerField(blank=True, null=False)
	Score_Final3 = models.IntegerField(blank=True, null=False)
	Score_Final4 = models.IntegerField(blank=True, null=False)

	def __unicode__(self):
		return "%s"%(self.Score_Final1+self.Score_Final2+self.Score_Final3+self.Score_Final4)

class CountGrade(models.Model):
	Section = models.IntegerField(blank=False, null=False)
	count_A  = models.IntegerField(blank=False, null=False)
	count_Bplus  = models.IntegerField(blank=False, null=False)
	count_B  = models.IntegerField(blank=False, null=False)
	count_Cplus  = models.IntegerField(blank=False, null=False)
	count_C  = models.IntegerField(blank=False, null=False) 
	count_Dplus  = models.IntegerField(blank=False, null=False)
	count_D  = models.IntegerField(blank=False, null=False) 
	count_F  = models.IntegerField(blank=False, null=False)

class User(models.Model):
	username = models.CharField(max_length=10,blank=False) 
	password = models.CharField(max_length=20,blank=False) 
	role = models.CharField(max_length=7,blank=False) 

class HistogramX(models.Model):
        numberX = models.IntegerField(max_length=10)
        positionX = models.IntegerField(max_length=10)
        feq = models.IntegerField(max_length=10)
        Grade = models.CharField(max_length=2)

class HistogramY(models.Model):
        numberY = models.IntegerField(max_length=10)
        positionY = models.IntegerField(max_length=10)
















